{
  "metadata": {
    "kernelspec": {
      "name": "xpython",
      "display_name": "Python 3.13 (XPython)",
      "language": "python"
    },
    "language_info": {
      "name": ""
    }
  },
  "nbformat_minor": 5,
  "nbformat": 4,
  "cells": [
    {
      "id": "caebcb1f-d8ba-4d6f-b0b3-31cad4f5f0f0",
      "cell_type": "code",
      "source": "import numpy as np\nimport pandas as pd\nimport statsmodels.api as sm\n\n# Simulated steady-state data (from previous simulation)\nomegas = np.array([0.05e6, 0.1e6, 0.2e6, 0.5e6])  # Rabi frequencies (MHz)\ngammas = np.array([0.05e6, 0.1e6, 0.2e6])          # Decoherence rates (MHz)\nsteady_state_data = []\nfor omega in omegas:\n    for gamma in gammas:\n        # Simplified steady-state calculation (placeholder, use actual data from simulation)\n        steady_pop = 0.5 * (1 - (omega / (omega + gamma))**2)  # Example model\n        steady_state_data.append([omega * 1e-6, gamma * 1e-6, steady_pop])\n\n# Convert to DataFrame\ndf = pd.DataFrame(steady_state_data, columns=['Omega (MHz)', 'Gamma (MHz)', 'Steady_State_Excited_Population'])\n\n# Calculate Omega/Gamma ratio\ndf['Omega_to_Gamma_Ratio'] = df['Omega (MHz)'] / df['Gamma (MHz)']\n\n# Perform OLS regression\nX = df['Omega_to_Gamma_Ratio']\nX = sm.add_constant(X)  # Add intercept term\ny = df['Steady_State_Excited_Population']\nmodel = sm.OLS(y, X).fit()\n\n# Extract regression results\nregression_results = [\n    ['Intercept', model.params[0], model.pvalues[0]],\n    ['Omega_to_Gamma_Ratio', model.params[1], model.pvalues[1]]\n]\n\n# Save to CSV\nregression_df = pd.DataFrame(regression_results, columns=['Variable', 'Coefficient', 'P_Value'])\nregression_df.to_csv('tls_regression_results.csv', index=False)",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": null
    },
    {
      "id": "ab0e9042-d201-4b48-b0af-9bdb666052a8",
      "cell_type": "code",
      "source": "",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": null
    }
  ]
}